// 管理弹出组件层级
import { defineStore } from 'pinia'
import { Ref, ref } from "vue";
export const useStore = defineStore('zIndex', () => {
  // lPopup层级
  const lPopup: Ref<number[]> = ref([]);
  // 下一个层级
  const nextLPopupMax = () => {
    let max = lPopup.value.length === 0 ? 100 : Math.max(...lPopup.value);
    let next = max + 1;
    lPopup.value.push(next);
    return next;
  }
  // 删除层级
  const preLPopupMax = (n: number) => {
    lPopup.value.splice(lPopup.value.findIndex(x => x === n), 1);
  }
  return {
    lPopup,
    nextLPopupMax,
    preLPopupMax,
  }
})
